﻿using INTEX.DataBase.Tools;
using ReflectionStudio.Core.Events;
using System;
using System.Data;
using System.Windows;
using System.Windows.Data;
using System.Data.OracleClient;
using ReflectionStudio.Components.UserControls;
using System.ComponentModel;
namespace WPFExcelReport
{
    public partial class TMAPCON
    {

        public TMAPCON()
        {
            MV = new VMAPCON();
            DataContext = MV;
            InitializeComponent();
            VAR = "E ";
        }
       
        public override void OnEXAUFChg(string value)
        {
            if (!IsCanLoad)
                return;
            TBMain.Clear();

            if (value == "")
                return;
            dwData = TBMain.NewRow();
            dwData["MCMANDANT"] = app.Mandant;
            dwData["MCNAME"] = value.PadRight(8).Substring(0,8);
            dwData["MCSPRKZ"] = VAR ;
             SResult = TMV.QMAPCON01(dwData);
            string file = ""; byte[] content;
            foreach (DataRow row in SResult.Tables[0].Rows)
            {
                
                content = (byte[])row["MCKONSTLST1"];
                continue;
                file = DateTime.Now.ToFileTime().ToString()+".txt";
                Helpers.Helper.byte2file(file, content);

                content = (byte[])row["MCKONSTLST2"];
                file = DateTime.Now.ToFileTime().ToString() + ".txt";
                Helpers.Helper.byte2file(file, content);

                content = (byte[])row["MCZZUSTAB1"];
                file = DateTime.Now.ToFileTime().ToString() + ".txt";
                Helpers.Helper.byte2file(file, content);

                content = (byte[])row["MCZZUSTAB2"];
                file = DateTime.Now.ToFileTime().ToString() + ".txt";
                Helpers.Helper.byte2file(file, content);

                content = (byte[])row["MCZZUSTAB3"];
                file = DateTime.Now.ToFileTime().ToString() + ".txt";
                Helpers.Helper.byte2file(file, content);
               
                row["KONSTLST1"] = Helpers.Helper.byte2str(content);
                content = (byte[])row["MCKONSTLST2"];
                row["KONSTLST2"] = Helpers.Helper.byte2str(content);
                content = (byte[])row["MCZZUSTAB1"];
                row["ZZUSTAB1"] = Helpers.Helper.byte2str(content);
                content = (byte[])row["MCZZUSTAB2"];
                row["ZZUSTAB2"] = Helpers.Helper.byte2str(content);
                content = (byte[])row["MCZZUSTAB3"];
                row["ZZUSTAB3"] = Helpers.Helper.byte2str(content);
            }
            MergeData(SResult, true);
            base.OnEXAUFChg(value);
        }
    }
}

